package com.Controller.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.Model.Pojo.Users;

import com.sql.DAO;

public class XiuGai extends HttpServlet {

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/html");
		request.setCharacterEncoding("UTF-8");
    	response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
    	HttpSession session = request.getSession(false);
    	
		String name = request.getParameter("name");
		String email = request.getParameter("Email");
		String shoujihao = request.getParameter("shoujihao");
		Users user = new Users();
		user = (Users)session.getAttribute("users");
		String sql;
		DAO dao = new DAO();
		sql = "update users set xingming='" + name + "' where name='" + user.getZhanghao() + "' ";
		dao.xiugai(sql);
		sql = "update users set youxiang='" + email + "' where name='" + user.getZhanghao() + "' ";
		dao.xiugai(sql);
		sql = "update users set shoujihao='" + shoujihao + "' where name='" + user.getZhanghao() + "' ";
		dao.xiugai(sql);
		user.setXingming(name);
		user.setYouxiang(email);
		user.setShoujihao(shoujihao);
		session.setAttribute("users", user);
		
		// 为JSP实例化一个请求分派器。
		response.sendRedirect("/Bank/WebPage/FrontPage/FinancialServicePage/PersonalInformation.jsp");
		out.flush();
		out.close();
		
	}

}
